C++ Regex 库

您所在的位置:网站首页 regex_replace函数 非汉字 C++ Regex 库

C++ Regex 库

2023-09-25 08:42| 来源: 网络整理| 查看: 265

❮ 上一节 下一节 ❯ C++ Regex 库 - regex_replace 描述

它制作目标序列(主题)的副本,其中正则表达式 rgx(模式)的所有匹配都被 fmt(替换)替换。 目标序列是 s 或介于 first 和 last 之间的字符序列,具体取决于使用的版本。

声明

以下是 std::regex_replace 的声明。

template basic_stringregex_replace (const charT* s, const basic_regex& rgx, const charT* fmt, C++11 template basic_stringregex_replace (const charT* s, const basic_regex& rgx, const charT* fmt, C++14 template basic_stringregex_replace (const charT* s, const basic_regex& rgx, const charT* fmt, 参数

s − 它是一个带有目标序列的字符串。

rgx − 它是要匹配的 basic_regex 对象。

flags − 用于控制 rgx 的匹配方式。

m − 它是 match_results 类型的对象。

返回值

它返回一个带有结果序列的字符串对象。

异常

No-noexcept − 这个成员函数从不抛出异常。

示例

在下面的 std::regex_replace 示例中。

#include #include #include #include int main () { std::string s ("there is a subsequence in the string\n"); std::regex e ("\\b(sub)([^ ]*)"); std::cout


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3